<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目名称">
              <j-input placeholder="请输入项目名称" v-model="queryParam.projectId"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="任务编码">
              <select-project-task-input
                :isRefresh="true"
                v-model="model.taskId"
                 />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="流程状态" >
              <j-dict-select-tag placeholder="请选择流程状态" v-model="queryParam.bpmStatus" dictCode="bpm_status"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset()" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:scrollX}"
        :components="draggableComponent"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <template slot="status" slot-scope="status">
          <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

      </a-table>
    </div>

    <erp-omc-project-task-modal ref="modalForm" @ok="modalFormOk"></erp-omc-project-task-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpOmcProjectTaskModal from './modules/ErpOmcProjectTaskModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'
import SelectProjectTaskInput from '@/views/scy/components/SelectProjectTaskInput'
export default {
  name: 'ErpOmcProjectTaskList',
  mixins: [JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
  components: {
    ErpOmcProjectTaskModal,
    SelectProjectTaskInput
  },
  data() {
    return {
      allowChange: false,
      description: '立项业务分类管理页面',
      model: {},
      //表头
      columns: [],
      //列设置
      settingColumns: [],
      // 列定义
      defColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '发起人',
          align: 'center',
          dataIndex: 'handlerId_dictText',
          width:164,
          ellipsis: true,
        },
        {
          title: '项目',
          align: 'center',
          dataIndex: 'projectName',
          width:124,
          ellipsis: true,
        },
        {
          title: '任务编号',
          align: 'center',
          dataIndex: 'taskId_dictText',
          width:202,
          ellipsis: true,
        },
        {
          title: '关联流程',
          align: 'center',
          dataIndex: 'type',
          width:202,
          ellipsis: true,
        },
        {
          title: '生产团队',
          align: 'center',
          dataIndex: 'productTeam_dictText',
          width:202,
          ellipsis: true,
        },
        {
          title: '经营团队',
          align: 'center',
          dataIndex: 'teamName_dictText',
          width:202,
          ellipsis: true,
        },
        {
          title: '流程状态',
          align: 'center',
          dataIndex: 'bpmStatus_dictText',
          width:202,
          ellipsis: true,
        },
        {
          title: '作废状态',
          align: 'center',
          dataIndex: 'isFlowCancel_dictText',
          width:202,
          ellipsis: true,
        }
      ],
      url: {
        list: '/api/erp/omc/project/erpOmcProjectTaskFinal/queryTaskStatusPageList'
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  /* watch:{
     allowChange:{

     }
   },*/
  methods: {
    setProjectId(projectId) {
      if (projectId) {
        this.queryParam.projectId = projectId
        this.loadData()
      }
    },
    getSelectedRowKeys() {
      var ids = ''
      for (var a = 0; a < this.selectedRowKeys.length; a++) {
        ids += this.selectedRowKeys[a] + ','
      }
      return ids
    },
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'categoryCode', text: '业务分类编码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'categoryName', text: '业务分类名称', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'contractRate', text: '合同占比（%）', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'contractAmount', text: '分配合同额（元）', dictCode: '' })
      fieldList.push({ type: 'string', value: 'productTeam', text: '生产团队', dictCode: '' })
      fieldList.push({ type: 'string', value: 'teamLeader', text: '团队负责人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'taskDescription', text: '任务说明', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
